{extend name="public/base"}

{block name="title"}
设置
{/block}

{block name="style"}
{css href="/static/wechat/css/set.css" /}
{/block}

{block name="body"}
<div class="pageControl setTelephone">
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">验证新手机</h1>
    </div>
    <div class="weui-top">
        <form>
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">新手机</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="tel" name="phone"  placeholder="请输入新手机号码">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">验证码</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="number" name="code" placeholder="请输入验证码">
                    </div>
                    <div class="weui-cell_ft">
                        <button class="weui_cell-verify js-verify cl-orange" >获取验证码</button>
                    </div>
                </div>
            </div>
            <div class="msui_button">
                <div class="msui_button-bd">
                    <a href="javascript:;" class="msui_button-content">确认修改</a>
                </div>
            </div>
        </form>
    </div>
</div>

<!-- loading toast -->
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">加载中...</p>
    </div>
</div>

{/block}

{block name="javascript"}
<script>
    $(function () {
        $(".msui_button-content").click(function () {
            if (!confirm('三个月内只能修改一次手机号码，请谨慎操作！！')) {
                return false;
            }
            $('#loadingToast').fadeIn();

            var code = $("input[name='code']").val();
            var phone = $("input[name='phone']").val();
            var type = {$type};

            $.ajax({
                type : 'POST',
                url : '?',
                data : {
                    code : code,
                    phone : phone
                },
                dataType : 'json',
                success : function (msg) {
                    $('#loadingToast').fadeOut();
                    if (msg.code == 200) {
                        alert('修改成功！！');
                        var urls = ['{:url("member/index")}','{:url("r_member/index")}','{:url("d_member/index")}','{:url("p_member/index")}'];
                        window.location.href = urls[type];
                    } else {
                        var code = msg.code;
                        $.alert(error_code[code]);
                    }
                }
            });
        });
    });
</script>
{/block}